<ui:composition xmlns:ui="http://java.sun.com/jsf/facelets"
   xmlns:f="http://java.sun.com/jsf/core"
   xmlns:h="http://java.sun.com/jsf/html"
   xmlns:c="http://java.sun.com/jstl/core"
   xmlns:af="http://myfaces.apache.org/trinidad"
   xmlns:afh="http://myfaces.apache.org/trinidad/html"
   xmlns:ppc="http://www.sungard.de/carnot/web/portal-plugin/common">
   
   <af:table binding="#{portalHeader.activityTable}" id="activityTable"
      value="#{portalHeader.currentActivities}" var="row"
      rowBandingInterval="1" width="100%" rows="#{portalHeader.chunkSize}"
      emptyText="#{commonMsg.noEntries}"
      partialTriggers=":bpmEvents:refreshEvent:full :bpmEvents:refreshEvent:workarea :taskTable:activityTable:chunksize"
      verticalGridVisible="false" rowSelection="#{(processPortalSettings.delegationMode eq 'multiple') ? 'multiple' : 'none'}"
      horizontalGridVisible="false" rangeChangeListener="#{portalHeader.onRangeChange}">

        <c:if test="#{processPortalSettings.delegationMode eq 'multiple'}">
           <f:facet name="footer">
               <af:panelButtonBar>
                   <af:commandButton id="delegationBtn"
                       action="#{portalHeader.delegateAction}"
                       text="#{commonMsg.delegate}"
                       immediate="true" partialSubmit="true"
                       useWindow="true" windowWidth="640" windowHeight="480"
                       launchListener="#{portalHeader.addSearchUserParameter}"
                       returnListener="#{portalHeader.delegateActivity}">
                   </af:commandButton>
               </af:panelButtonBar>
           </f:facet>
        </c:if>
        
      <c:if test="#{taskTableWithActions}">
         <f:facet name="actions">
                <af:panelGroupLayout layout="vertical">
                    <af:inputText id="chunksize"
                        label="#{commonMsg.chunksize}" columns="3"
                        value="#{portalHeader.chunkSize}" autoSubmit="true"
                        partialTriggers="activityTable"
                        onkeyup="submitForm_afterEnter(event, form)"
                        rendered="#{not portalHeader.activityTable.showAll}">
                        <af:convertNumber integerOnly="true"/>
                        <af:validateLongRange minimum="1"/>
                    </af:inputText>
                    <ppc:columnFilter selectedColumns="#{portalHeader.columnFilterHandler.selectedColumns}" allColumns="#{portalHeader.columnFilterHandler.allColumns}" />
                </af:panelGroupLayout>
         </f:facet>
      </c:if>     
      
      <af:column id="activityNameCol" sortable="false" sortProperty="reset-sorting"
         separateRows="true" styleClass="taskTable_activityNameCol">

         <f:facet name="header">
                <ui:include src="column-header.xhtml">
                    <ui:param name="columnHeading" value="#{commonMsg.name}" />

                    <ui:param name="columnFieldType" value="ActivityName" />
                    <ui:param name="filterEnabled" value="true" />
                    <ui:param name="columnFieldModel" value="#{portalHeader.activityNameFilterModel}" />
                    <ui:param name="sortEnabled" value="false" />
                </ui:include>
         </f:facet>

            <af:group>
                <af:commandLink 
                    action="#{taskTableLaunchActivityDelegate.launchWorkshopActivity}"
                    immediate="true" useWindow="false" id="launchActivity"
                    returnListener="#{portalHeader.returnActivity}"
                    partialSubmit="true" 
                    disabled="#{portalHeader.worklistReadOnly or (row.userPerformerOID != 0 and row.userPerformerOID != sessionContext.user.OID)}">

                    <af:setActionListener from="#{row}"
                        to="#{pageFlowScope.selectedActivityInstance}" />

                    <af:setActionListener from="#{row.resubmissionDate}"
                        to="#{pageFlowScope.predefinedResubmissionDate}" />

                    <af:outputFormatted value="#{row.activity}" styleClass="activityNameText"
                        converter="modelElementLabelProvider"/>
                </af:commandLink>
                <af:outputFormatted value="#{row}" styleClass="descriptorOutlineText"
                        converter="tasksTableDescriptorOutlineProvider" />
            </af:group>            
      </af:column>

        <c:forEach var="item" varStatus="status" items="#{portalHeader.descriptors}">
            <ui:include src="descriptor-column.xhtml">
                <ui:param name="descriptor" value="#{item.dataPath}" />
                <ui:param name="descriptorFilter" value="#{item.descriptorField}" />
                <ui:param name="descriptorFilterFieldId"
                    value="filterFieldDescriptor_#{status.index}" />
                <ui:param name="colStyleClassPrefix" value="taskTable_" />
                <ui:param name="filterEnabled" value="#{portalHeader.descriptorFilterFieldEnabled and item.filterable}" />
                <ui:param name="sortEnabled" value="#{item.sortable}" />
                <ui:param name="sortModel" value="#{portalHeader}" />
                <ui:param name="sortProperty" value="#{item.sortProperty}" />
            </ui:include>
        </c:forEach>

      <af:column id="startTimeCol" styleClass="taskTable_startTimeCol" rendered="#{portalHeader.columnFilterHandler.columnVisibility['startTime'].visible}">

         <f:facet name="header">

            <ui:include src="column-header.xhtml">
               <ui:param name="columnHeading" value="#{commonMsg.startTime}" />

               <ui:param name="columnFieldType" value="TimeStamp" />
               <ui:param name="columnFilterOpDefault" value="greaterOrEqual" />
                    <ui:param name="filterEnabled" value="true" />
                    <ui:param name="columnFieldModel" value="#{portalHeader.startTimeFilterModel}" />
               <ui:param name="sortEnabled" value="#{not empty portalHeader.currentWorklistModel}" />
               <ui:param name="sortModel" value="#{portalHeader}" />
               <ui:param name="sortProperty" value="startTime" />
            </ui:include>

         </f:facet>

         <af:outputText value="#{row.startTime}">
            <af:convertDateTime type="both" pattern="#{dateUtils.dateFormatter}" />
         </af:outputText>
      </af:column>

      <af:column id="lastModifiedCol" styleClass="taskTable_lastModifiedCol" rendered="#{portalHeader.columnFilterHandler.columnVisibility['lastModified'].visible}">

         <f:facet name="header">

            <ui:include src="column-header.xhtml">
               <ui:param name="columnHeading" value="#{commonMsg.lastModified}" />

               <ui:param name="columnFieldType" value="TimeStamp" />
               <ui:param name="columnFilterOpDefault" value="lessOrEqual" />

               <ui:param name="sortEnabled" value="#{not empty portalHeader.currentWorklistModel}" />
               <ui:param name="sortModel" value="#{portalHeader}" />
               <ui:param name="sortProperty" value="lastModificationTime" />
            </ui:include>

         </f:facet>

         <af:outputText value="#{row.lastModificationTime}">
            <af:convertDateTime type="both" pattern="#{dateUtils.dateFormatter}" />
         </af:outputText>
      </af:column>
            
        <af:column id="lastPerformerCol" styleClass="taskTable_lastPerformerCol"
            rendered="#{processPortalSettings.historicalStatesAvailable and portalHeader.columnFilterHandler.columnVisibility['lastPerformer'].visible}" seperateRows="true"
            sortable="false" sortProperty="reset-sorting">

            <f:facet name="header">
                <af:outputText value="#{commonMsg.lastPerformer}" />
            </f:facet>

            <af:outputText value="#{row.lastPerformer}"/>
        </af:column>

      <af:column id="iconCol" formatType="icon" styleClass="taskTable_iconCol" rendered="#{portalHeader.columnFilterHandler.columnVisibility['buttonBar'].visible}">

         <f:facet name="header">
            <af:outputText value="" />
         </f:facet>

         <af:group>
            <af:commandNavigationItem id="delegationIcon"
               action="dialog:delegate"
               shortDesc="#{commonMsg.delegate}"
               immediate="true" partialSubmit="true"
               useWindow="true" windowWidth="640" windowHeight="480"
               launchListener="#{portalHeader.addSearchUserParameter}"
               returnListener="#{portalHeader.delegateActivity}"
               rendered="#{processPortalSettings.delegationMode eq 'single'}">
               <af:icon name="activityDelegate"/>
               <af:setActionListener from="#{row}"
                  to="#{pageFlowScope.selectedActivityInstance}" />
            </af:commandNavigationItem>
            <af:commandNavigationItem id="processHistory"
               shortDesc="#{localeBundle.processHistory}"
               action="dialog:processHistory" useWindow="true"
               launchListener="#{processHistoryDialog.prepareDialog}"
               windowWidth="640" windowHeight="480" partialSubmit="true"
               immediate="true">
               <f:attribute name="activityInstanceForProcessHistory" value="#{row}"/>
               <af:icon name="activityProcessHistory"/>
            </af:commandNavigationItem>
            <af:commandNavigationItem id="activityDetails"
               shortDesc="#{localeBundle.activityDetails}"
               action="dialog:activityDetails" useWindow="true"
               windowWidth="480" windowHeight="480" partialSubmit="true"
               launchListener="#{activityMetadataDialog.prepareDialog}"
               styleClass="activityPanelIcon"
               immediate="true">
               <f:attribute name="activityInstanceForDetails" value="#{row}"/>
               <af:icon name="activityDetails"/>
            </af:commandNavigationItem>
            <af:icon name="activityEmptyNote" 
               rendered="#{not row.scopeProcessInstanceNoteAvailable}"
               shortDesc="#{commonMsg.noNoteAvailable}"/>
            <af:commandNavigationItem id="activityNotes"
               action="dialog:notes" launchListener="#{activityInstanceNotes.prepareDialog}"
               rendered="#{row.scopeProcessInstanceNoteAvailable}"
               useWindow="true" windowWidth="640" windowHeight="480"
               partialSubmit="true" immediate="true"
               styleClass="activityPanelIcon">
               <f:attribute name="currentActivityInstance"
                  value="#{row}"/>
               <af:icon name="activityNote"/>
            </af:commandNavigationItem>
            <ppc:abortActivityPanel activityToAbort="#{row}" abortActivityMethod="#{portalHeader.abortActivity}" isAbortable="#{row.activityAbortable}" />
            
            <c:if test="#{ not empty infinityPortalCustomization.taskActionsInclude}">
		 	    <ui:include src="#{infinityPortalCustomization.taskActionsInclude}"/>
            </c:if>

         </af:group>

      </af:column>
        
      <c:if test="#{not empty pageFlowScope.columnPageForTasksTable}">
         <ui:include src="#{pageFlowScope.columnPageForTasksTable}"/>
      </c:if>
        
   </af:table>
   
</ui:composition>

